Java2D: if statement doesn`t work with java.awt.Color
Posted
by
DarkSun
on Stack Overflow
See other posts from Stack Overflow
or by DarkSun
Published on 2012-04-07T11:23:26Z
Indexed on
2012/04/07
11:28 UTC
Read the original article
Hit count: 172
I have a getPixelColour function:
Color getPixelColor(int x, int y) {
if(mazeImage == null) System.out.println(":(");
int pixel = mazeImage.getRGB(x, y);
int red = (pixel & 0x00ff0000) >> 16;
int green = (pixel & 0x0000ff00) >> 8;
int blue = pixel & 0x000000ff;
return new Color(red,green,blue);
}
For example a pixel is black, and System.out.println(getPixelColor(x,y) + " " + Color.BLACK); writes "java.awt.Color[r=0,g=0,b=0] java.awt.Color[r=0,g=0,b=0]"
But getPixelColor(x,y) == Color.BLACK return false. What's wrong with it?
© Stack Overflow or respective owner